package com.example.RouterHandle;

import android.util.Log;
import android.view.View;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class GoEvent implements View.OnClickListener {

    private static Map<Integer, RouterFunction> handleMap = new HashMap<>();

    @Override
    public void onClick(View v) {
        handleMap.get(v.getId()).to(v.getContext());
    }

    public static void registerFunction(Integer integer, RouterFunction routerFunction) {
        if (integer == null || routerFunction == null) {
            Log.e(GoEvent.class.getName(), "register error: key or value is null");
            return;
        }
        handleMap.put(integer, routerFunction);
    }

    public static Set<Integer> getIdsOfHandles() {
        return handleMap.keySet();
    }
}
